package dao.hibernate;

import java.util.List;

import dao.ChuDeKhacDAO;
import model.ChuDeKhac;

public class ChuDeKhacDAOHibernate extends GenericHibernateDAO<ChuDeKhac, Long>
		implements ChuDeKhacDAO {

	@SuppressWarnings("unchecked")
	@Override
	public List<ChuDeKhac> findByTenChuDeKhacLike(String keyword) {
		return getSession()
				.createQuery(
						"FROM ChuDeKhac AS chuDeKhac WHERE chuDeKhac.tenChuDe LIKE :pname")
				.setString("pname", "%" + keyword + "%").list();
	}

	@Override
	public ChuDeKhac findChuDeChaByLoai(String loai) {
		return (ChuDeKhac) getSession()
				.createQuery(
						"FROM ChuDeKhac AS chuDeKhac WHERE chuDeKhac.loaiChuDeKhac = :pname")
				.setString("pname", loai).uniqueResult();

	}
}
